#include <stdio.h>

int halfSerchRecursive(int* arr, int low, int high, int key);

int main(int argc, char** argv) {
	int arr[5] = {1, 2, 3};
	int result;

	result = halfSerchRecursive(arr, 0, 2, 3);
	if (result == -1) {
		printf("No Result!");
	}
	else {
		printf("Result index is: %d", result);
	}

	return 0;
}
// 已经很好的说明了为什么mid要+1-1变low和high
int halfSerchRecursive(int* arr, int low, int high, int key) {
	int mid;
	if (low > high) return -1;
	else {
		mid = (low + high) / 2;
		if (arr[mid] == key) return mid;
		else if (arr[mid] < key) halfSerchRecursive(arr, mid + 1, high, key);
		else halfSerchRecursive(arr, low, mid - 1, key);
	}
}
